<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        .fade-enter-active, .fade-leave-active{
            transition: opacity .5s ease;
        }
        .fade-enter, .fade-leave-to{
          opacity:0;
        }
    </style>
</head>
<body>
    <template  id="example1"><span>我是登陆组件</span></template>
    <template  id="example2"><span>我是注册组件</span></template>
    <div id="app">
        <a href="javascript:;" @click="componentName='exmaple1'" >登陆</a>
        <a href="javascript:;" @click="componentName='exmaple2'" >注册</a>
        <transition name="fade" mode="in-out">
            <component :is="componentName"></component>
            <exmaple1 if="true"></exmaple1>
            <exmaple2 if="else"></exmaple2>
        </transition>
    </div>
    <script>
    Vue.component('example1',{template:'#example1'})
    Vue.component('example2',{template:'#example2'})
    var vm =new Vue({
        el:"#app",
        data:{componentName:''}
    })
    </script>
</body>
</html>